package com.tdh.tlgusers.controller;

import com.tdh.tlgusers.pojo.Address;
import com.tdh.tlgusers.service.AddressService;
import com.tdh.tlgusers.util.Record;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class AddressController {
    @Autowired
    private AddressService addressService;

    @GetMapping("/selAddress")
    public Record selAllAddress(Integer userId){
        return addressService.selAddress(userId);
    }

    @PostMapping("/addAddress")
    public Record addAddress(@RequestBody Address address){
        return addressService.addAddress(address);
    }

    @GetMapping("/delAddress")
    public Record delete(Integer addressId){
        return addressService.deleteAddress(addressId);
    }

    @PostMapping("/modifyAddress")
    public Record modifyAddress(@RequestBody Address address){
        return addressService.modifyAddress(address);
    }
}
